<%@ page contentType="text/html; charset=utf-8" %>
<%@ include file="common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>检测用户注册信息</title>
        <link href="CSS/style1.css" rel="stylesheet">
    </head>
    <body>
        
        
        <%
            request.setCharacterEncoding("utf-8");
            String username = request.getParameter("UserName");
            java.util.Collection l = bookDB.getMemberName(username);
            java.util.Iterator i = l.iterator();      
            if (i.hasNext()) {
                out.println("<script language='javascript'>alert('该用户名已经存在，请重新注册！');window.location.href='register.jsp';</script>");
            } else {
                String truename = request.getParameter("TrueName");
                String PWD = request.getParameter("PWD1");
                String cardNO = request.getParameter("cardNO");
                String CardType = request.getParameter("CardType");
                String tel = request.getParameter("tel");
                String city = request.getParameter("city");
                String address = request.getParameter("address");
                String postcode = request.getParameter("postcode");
                String Email = request.getParameter("Email");
                
                   Member1 member = new Member1();
              
                member.setUsername(username);
                member.setPassWord(PWD);
                member.setAddress(address);
                member.setCardNO(cardNO);
                member.setCardType(CardType);
                member.setCity(city);
                member.setEmail(Email);
                member.setPostcode(postcode);
                member.setTrueName(truename);
                member.setTel(tel);
              int res=bookDB.add(member);
              if (res==0){
                out.println("<script language='javascript'>alert('用户注册成功！');window.location.href='bookstore.jsp';</script>");
             }else{
                  out.println("<script language='javascript'>alert('用户注册失败！');window.location.href='register.jsp';</script>");
             }
            }
           
        %>
    </body>
</html>

